 package server.maps;


import com.alibaba.druid.pool.DruidPooledConnection;
import configs.ServerConfig;
import constants.BattleConstants;
import constants.GameConstants;
import database.DatabaseConnection;
import provider.*;
import server.MaplePortal;
import server.life.AbstractLoadedMapleLife;
import server.life.MapleHideNpc;
import server.life.MapleLifeFactory;
import server.life.MapleMonster;
import tools.Pair;
import tools.Randomizer;
import tools.StringUtil;
import tools.config.BmsSerUtil;

import java.awt.*;
import java.io.File;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;




























 public class MapleMapFactory {
/*   31 */   private static final MapleDataProvider source = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Map.wz"));
/*   32 */   private static final MapleData nameData = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/String.wz")).getData("Map.img");
/*   33 */   private final HashMap<Integer, MapleMap> maps = new HashMap<>();
/*   34 */   private final HashMap<Integer, MapleMap> instanceMap = new HashMap<>();
/*   35 */   private final ReentrantLock lock = new ReentrantLock();
   private int channel;
/*   37 */   private Map<Integer, List<Integer>> linknpcs = new HashMap<>();

/*   39 */   private static  Map<Integer, List<Integer>> mapLinknpcs = new HashMap<>();
/*   40 */   private static final Map<Integer, String> allMapNames = new HashMap<>();

   public MapleMapFactory(int channel) {
/*   43 */     this.channel = channel;
   }

   public static void loadAllMapName() {
/*   47 */     for (MapleData mapleData : nameData) {
/*   48 */       for (MapleData data : mapleData) {
/*   49 */         for (MapleData subdata : data) {
/*   50 */           if (subdata.getName().equalsIgnoreCase("mapName")) {
/*   51 */             allMapNames.put(Integer.valueOf(data.getName()), subdata.getData().toString());
           }
         }
       }
     }
   }

   public static String getMapName(int mapid) {
/*   59 */     return allMapNames.get(Integer.valueOf(mapid));
   }

   public static Map<Integer, String> getAllMapName() {
/*   63 */     return allMapNames;
   }

   public static void loadAllLinkNpc() {


                String filename="ser/NpcData.ser";

                if(BmsSerUtil.checkFileExists(filename)){
                    mapLinknpcs=(Map<Integer, List<Integer>>)BmsSerUtil.getDataFromSer(filename);
                }else{
/*   67 */     for (MapleDataDirectoryEntry directoryEntry : source.getRoot().getSubdirectories()) {
/*   68 */       if (directoryEntry.getName().equals("Map")) {
/*   69 */         for (MapleDataDirectoryEntry directoryEntry1 : directoryEntry.getSubdirectories()) {
/*   70 */           if (directoryEntry1.getName().startsWith("Map")) {
/*   71 */             for (MapleDataFileEntry fileEntry : directoryEntry1.getFiles()) {
/*   72 */               for (MapleData life : source.getData(directoryEntry.getName() + "/" + directoryEntry1.getName() + "/" + fileEntry.getName())) {
/*   73 */                 if (life.getName().equals("life")) {
/*   74 */                   List<Integer> npcids = new ArrayList<>();
/*   75 */                   for (MapleData mapleData : life) {
/*   76 */                     MapleData type1 = mapleData.getChildByPath("type");
/*   77 */                     if (type1 == null) {
                       continue;
                     }
/*   80 */                     String type = MapleDataTool.getString(type1);
/*   81 */                     if (type != null && type.equals("n")) {
/*   82 */                       npcids.add(Integer.valueOf(MapleDataTool.getIntConvert(mapleData.getChildByPath("id"), 0)));
                     }
                   }
/*   85 */                   if (!npcids.isEmpty()) {
/*   86 */                     mapLinknpcs.put(Integer.valueOf(fileEntry.getName().substring(0, 9)), npcids);
                   }
                 }
               }
             }
           }
         }
       }
     }
                BmsSerUtil.makeSerFile(filename,mapLinknpcs);
                }
   }

   public static Map<Integer, List<Integer>> getAllLinkNpc() {
/*   98 */     return mapLinknpcs;
   }




   private static String getMapXMLName(int mapid) {
/*  105 */     String mapName = StringUtil.getLeftPaddedStr(Integer.toString(mapid), '0', 9);
/*  106 */     String builder = "Map/Map" + (mapid / 100000000) + "/" + mapName + ".img";



/*  110 */     mapName = builder;
/*  111 */     return mapName;
   }

   public MapleMap getMap(int mapid) {
/*  115 */     return getMap(mapid, true, true, true);
   }


   public MapleMap getMap(int mapid, boolean respawns, boolean npcs) {
/*  120 */     return getMap(mapid, respawns, npcs, true);
   }

   public MapleMap getMap(int mapid, boolean respawns, boolean npcs, boolean reactors) {
/*  124 */     Integer omapid = Integer.valueOf(mapid);
/*  125 */     MapleMap map = this.maps.get(omapid);
/*  126 */     if (map == null) {
/*  127 */       this.lock.lock(); try {
         MapleData mapData;
/*  129 */         map = this.maps.get(omapid);
/*  130 */         if (map != null) {
/*  131 */           return map;
         }

         try {
/*  135 */           mapData = source.getData(getMapXMLName(mapid));
/*  136 */         } catch (Exception e) {
/*  137 */           return null;
         }
/*  139 */         if (mapData == null) {
/*  140 */           return null;
         }
/*  142 */         int linkMapId = -1;
/*  143 */         MapleData link = mapData.getChildByPath("info/link");
/*  144 */         if (link != null) {
/*  145 */           linkMapId = MapleDataTool.getIntConvert("info/link", mapData);
/*  146 */           mapData = source.getData(getMapXMLName(linkMapId));
         }

/*  149 */         float monsterRate = 0.0F;
/*  150 */         if (respawns) {
/*  151 */           MapleData mobRate = mapData.getChildByPath("info/mobRate");
/*  152 */           if (mobRate != null) {
/*  153 */             monsterRate = ((Float)mobRate.getData()).floatValue();
           }
         }


/*  158 */         int freeMarket = mapid % 910000000;
/*  159 */         if (freeMarket >= 1 && freeMarket <= 22) {
/*  160 */           map = new MapleMap(GameConstants.getOverrideChangeToMap(mapid), this.channel, mapid, monsterRate);
         } else {
/*  162 */           map = new MapleMap(mapid, this.channel, MapleDataTool.getInt("info/returnMap", mapData), monsterRate);
         }

/*  165 */         loadPortals(map, mapData.getChildByPath("portal"));
/*  166 */         map.setTop(MapleDataTool.getInt(mapData.getChildByPath("info/VRTop"), 0));
/*  167 */         map.setLeft(MapleDataTool.getInt(mapData.getChildByPath("info/VRLeft"), 0));
/*  168 */         map.setBottom(MapleDataTool.getInt(mapData.getChildByPath("info/VRBottom"), 0));
/*  169 */         map.setRight(MapleDataTool.getInt(mapData.getChildByPath("info/VRRight"), 0));
/*  170 */         if (MapleDataTool.getInt(mapData.getChildByPath("info/fieldType"), 0) != 0) {
/*  171 */           map.setFieldType(MapleDataTool.getInt(mapData.getChildByPath("info/fieldType"), 0));
         }

/*  174 */         List<MapleFoothold> allFootholds = new LinkedList<>();
/*  175 */         Point lBound = new Point();
/*  176 */         Point uBound = new Point();


/*  179 */         for (MapleData footRoot : mapData.getChildByPath("foothold")) {
/*  180 */           for (MapleData footCat : footRoot) {
/*  181 */             for (MapleData footHold : footCat) {






/*  188 */               MapleFoothold fh = new MapleFoothold(new Point(MapleDataTool.getInt(footHold.getChildByPath("x1"), 0), MapleDataTool.getInt(footHold.getChildByPath("y1"), 0)), new Point(MapleDataTool.getInt(footHold.getChildByPath("x2"), 0), MapleDataTool.getInt(footHold.getChildByPath("y2"), 0)), Integer.parseInt(footHold.getName()));
/*  189 */               fh.setPrev((short)MapleDataTool.getInt(footHold.getChildByPath("prev"), 0));
/*  190 */               fh.setNext((short)MapleDataTool.getInt(footHold.getChildByPath("next"), 0));

/*  192 */               if (fh.getX1() < lBound.x) {
/*  193 */                 lBound.x = fh.getX1();
               }
/*  195 */               if (fh.getX2() > uBound.x) {
/*  196 */                 uBound.x = fh.getX2();
               }
/*  198 */               if (fh.getY1() < lBound.y) {
/*  199 */                 lBound.y = fh.getY1();
               }
/*  201 */               if (fh.getY2() > uBound.y) {
/*  202 */                 uBound.y = fh.getY2();
               }
/*  204 */               allFootholds.add(fh);
             }
           }
         }
/*  208 */         MapleFootholdTree fTree = new MapleFootholdTree(lBound, uBound);
/*  209 */         for (MapleFoothold foothold : allFootholds) {
/*  210 */           fTree.insert(foothold);
         }
/*  212 */         map.setFootholds(fTree);
/*  213 */         if (map.getTop() == 0) {
/*  214 */           map.setTop(lBound.y);
         }
/*  216 */         if (map.getBottom() == 0) {
/*  217 */           map.setBottom(uBound.y);
         }
/*  219 */         if (map.getLeft() == 0) {
/*  220 */           map.setLeft(lBound.x);
         }
/*  222 */         if (map.getRight() == 0) {
/*  223 */           map.setRight(uBound.x);
         }
/*  225 */         int bossid = -1;
/*  226 */         String msg = null;
/*  227 */         if (mapData.getChildByPath("info/timeMob") != null) {
/*  228 */           bossid = MapleDataTool.getInt(mapData.getChildByPath("info/timeMob/id"), 0);
/*  229 */           msg = MapleDataTool.getString(mapData.getChildByPath("info/timeMob/message"), null);
         }

/*  232 */         try (DruidPooledConnection con = DatabaseConnection.getInstance().getConnection()) {
/*  233 */           PreparedStatement ps = con.prepareStatement("SELECT * FROM spawns WHERE mid = ?");
                ps.setInt(1, omapid);
                ResultSet rs = ps.executeQuery();
                while (rs.next()) {
                    int sqlid = rs.getInt("idd");
                    int sqlf = rs.getInt("f");
                    boolean sqlhide = false;
                    String sqltype = rs.getString("type");
                    int sqlfh = rs.getInt("fh");
                    int sqlcy = rs.getInt("cy");
                    int sqlrx0 = rs.getInt("rx0");
                    int sqlrx1 = rs.getInt("rx1");
                    int sqlx = rs.getInt("x");
                    int sqly = rs.getInt("y");
                    int sqlmobTime = rs.getInt("mobtime");
                    AbstractLoadedMapleLife sqlmyLife = loadLife(sqlid, sqlf, sqlhide, sqlfh, sqlcy, sqlrx0, sqlrx1, sqlx, sqly, sqltype, mapid);
                    switch (sqltype) {
                        case "n":
                            map.addMapObject(sqlmyLife);
                            break;
                        case "m":
                            MapleMonster monster = (MapleMonster) sqlmyLife;
                            map.addMonsterSpawn(monster, sqlmobTime, (byte) -1, null);
                            break;
                    }
                }
/*  259 */         } catch (SQLException e) {
/*  260 */           System.out.println("读取SQL刷Npc和刷新怪物出错.");
         }




/*  266 */         List<Point> herbRocks = new ArrayList<>();
/*  267 */         int lowestLevel = 200, highestLevel = 0;



/*  271 */         for (MapleData life : mapData.getChildByPath("life")) {
/*  272 */           String id = MapleDataTool.getString(life.getChildByPath("id"));
/*  273 */           String type = MapleDataTool.getString(life.getChildByPath("type"));
/*  274 */           String limited = MapleDataTool.getString("limitedname", life, "");
/*  275 */           if ((npcs || !type.equals("n")) && !limited.equals("Stage0")) {
/*  276 */             AbstractLoadedMapleLife myLife = loadLife(life, id, type, mapid);

/*  278 */             if (myLife instanceof MapleMonster && !BattleConstants.isBattleMap(mapid) && !GameConstants.isNoSpawn(mapid)) {
/*  279 */               MapleMonster mob = (MapleMonster)myLife;

/*  281 */               herbRocks.add(map.addMonsterSpawn(mob, MapleDataTool.getInt("mobTime", life, 0), (byte)MapleDataTool.getInt("team", life, -1), (mob.getId() == bossid) ? msg : null).getPosition());
/*  282 */               if (mob.getStats().getLevel() > highestLevel && !mob.getStats().isBoss()) {
/*  283 */                 highestLevel = mob.getStats().getLevel();
               }
/*  285 */               if (mob.getStats().getLevel() < lowestLevel && !mob.getStats().isBoss())
/*  286 */                 lowestLevel = mob.getStats().getLevel();  continue;
             }
/*  288 */             if (myLife instanceof server.life.MapleNPC) {
/*  289 */               for (MapleHideNpc h : MapleHideNpc.values()) {
/*  290 */                 if (Integer.parseInt(id) == h.getNpcId()) {
/*  291 */                   map.addHideNpc(h);
                 }
               }
/*  294 */               map.addMapObject((MapleMapObject)myLife);
             }
           }
         }
/*  298 */         addAreaBossSpawn(map);
/*  299 */         map.setCreateMobInterval((short)MapleDataTool.getInt(mapData.getChildByPath("info/createMobInterval"), ServerConfig.CHANNEL_MONSTER_REFRESH * 1000));
/*  300 */         map.setFixedMob(MapleDataTool.getInt(mapData.getChildByPath("info/fixedMobCapacity"), 0));
/*  301 */         map.setPartyBonusRate(GameConstants.getPartyPlay(mapid, MapleDataTool.getInt(mapData.getChildByPath("info/partyBonusR"), 0)));
/*  302 */         map.loadMonsterRate(true);
/*  303 */         map.setNodes(loadNodes(mapid, mapData));
/*  304 */         map.setSpawnPoints(herbRocks);




/*  309 */         if (reactors && mapData.getChildByPath("reactor") != null && !BattleConstants.isBattleMap(mapid)) {
/*  310 */           for (MapleData reactor : mapData.getChildByPath("reactor")) {
/*  311 */             String id = MapleDataTool.getString(reactor.getChildByPath("id"));
/*  312 */             if (id != null) {
/*  313 */               map.spawnReactor(loadReactor(reactor, id, (byte)MapleDataTool.getInt(reactor.getChildByPath("f"), 0)));
             }
           }
         }
/*  317 */         map.setFirstUserEnter(MapleDataTool.getString(mapData.getChildByPath("info/onFirstUserEnter"), ""));
/*  318 */         map.setUserEnter((mapid == 180000001) ? "jail" : MapleDataTool.getString(mapData.getChildByPath("info/onUserEnter"), ""));
/*  319 */         if (reactors && herbRocks.size() > 0 && highestLevel >= 30 && map.getFirstUserEnter().equals("") && map.getUserEnter().equals("")) {
/*  320 */           List<Integer> allowedSpawn = new ArrayList<>(24);
/*  321 */           allowedSpawn.add(Integer.valueOf(100011));
/*  322 */           allowedSpawn.add(Integer.valueOf(200011));
/*  323 */           if (highestLevel >= 100) {
/*  324 */             for (int j = 0; j < 10; j++) {
/*  325 */               for (int x = 0; x < 4; x++) {
/*  326 */                 allowedSpawn.add(Integer.valueOf(100000 + j));
/*  327 */                 allowedSpawn.add(Integer.valueOf(200000 + j));
               }
             }
           } else {
/*  331 */             for (int j = (lowestLevel % 10 > highestLevel % 10) ? 0 : (lowestLevel % 10); j < highestLevel % 10; j++) {
/*  332 */               for (int x = 0; x < 4; x++) {
/*  333 */                 allowedSpawn.add(Integer.valueOf(100000 + j));
/*  334 */                 allowedSpawn.add(Integer.valueOf(200000 + j));
               }
             }
           }
/*  338 */           int numSpawn = Randomizer.nextInt(allowedSpawn.size()) / 6;
/*  339 */           for (int i = 0; i < numSpawn && !herbRocks.isEmpty(); i++) {
/*  340 */             int idd = ((Integer)allowedSpawn.get(Randomizer.nextInt(allowedSpawn.size()))).intValue();
/*  341 */             int theSpawn = Randomizer.nextInt(herbRocks.size());
/*  342 */             MapleReactor myReactor = new MapleReactor(MapleReactorFactory.getReactor(idd), idd);
/*  343 */             myReactor.setPosition(herbRocks.get(theSpawn));
/*  344 */             myReactor.setDelay((idd % 100 == 11) ? 60000 : 5000);
/*  345 */             map.spawnReactor(myReactor);
/*  346 */             herbRocks.remove(theSpawn);
           }
         }



         try {
/*  353 */           map.setMapName(MapleDataTool.getString("mapName", nameData.getChildByPath(getMapStringName((linkMapId > 0) ? linkMapId : omapid.intValue())), ""));
/*  354 */           map.setStreetName(MapleDataTool.getString("streetName", nameData.getChildByPath(getMapStringName((linkMapId > 0) ? linkMapId : omapid.intValue())), ""));
/*  355 */         } catch (Exception e) {
/*  356 */           map.setMapName("");
/*  357 */           map.setStreetName("");
         }



/*  362 */         map.setClock((mapData.getChildByPath("clock") != null));
/*  363 */         map.setEverlast((MapleDataTool.getInt(mapData.getChildByPath("info/everlast"), 0) > 0));
/*  364 */         map.setTown((MapleDataTool.getInt(mapData.getChildByPath("info/town"), 0) > 0));
/*  365 */         map.setSoaring((MapleDataTool.getInt(mapData.getChildByPath("info/needSkillForFly"), 0) > 0));
/*  366 */         map.setPersonalShop((MapleDataTool.getInt(mapData.getChildByPath("info/personalShop"), 0) > 0));
/*  367 */         map.setEntrustedFishing((MapleDataTool.getInt(mapData.getChildByPath("info/entrustedFishing"), 0) > 0));
/*  368 */         map.setForceMove(MapleDataTool.getInt(mapData.getChildByPath("info/lvForceMove"), 0));
/*  369 */         map.setHPDec(MapleDataTool.getInt(mapData.getChildByPath("info/decHP"), 0));
/*  370 */         map.setHPDecInterval(MapleDataTool.getInt(mapData.getChildByPath("info/decHPInterval"), 10000));
/*  371 */         map.setHPDecProtect(MapleDataTool.getInt(mapData.getChildByPath("info/protectItem"), 0));
/*  372 */         map.setForcedReturnMap((mapid == 0) ? 999999999 : MapleDataTool.getInt(mapData.getChildByPath("info/forcedReturn"), 999999999));
/*  373 */         map.setTimeLimit(MapleDataTool.getInt(mapData.getChildByPath("info/timeLimit"), -1));
/*  374 */         map.setFieldLimit(MapleDataTool.getInt(mapData.getChildByPath("info/fieldLimit"), 0));
/*  375 */         map.setMiniMapOnOff((MapleDataTool.getInt(mapData.getChildByPath("info/miniMapOnOff"), 0) > 0));
/*  376 */         map.setRecoveryRate(MapleDataTool.getFloat(mapData.getChildByPath("info/recovery"), 1.0F));
/*  377 */         map.setFixedMob(MapleDataTool.getInt(mapData.getChildByPath("info/fixedMobCapacity"), 0));
/*  378 */         map.setPartyBonusRate(GameConstants.getPartyPlay(mapid, MapleDataTool.getInt(mapData.getChildByPath("info/partyBonusR"), 0)));
/*  379 */         map.setConsumeItemCoolTime(MapleDataTool.getInt(mapData.getChildByPath("info/consumeItemCoolTime"), 0));

/*  381 */         this.maps.put(omapid, map);
       } finally {
/*  383 */         this.lock.unlock();
       }
     }
/*  386 */     return map;
   }

   public MapleMap getInstanceMap(int instanceid) {
/*  390 */     return this.instanceMap.get(Integer.valueOf(instanceid));
   }

   public void removeInstanceMap(int instanceid) {
/*  394 */     this.lock.lock();
     try {
/*  396 */       if (isInstanceMapLoaded(instanceid)) {
/*  397 */         getInstanceMap(instanceid).checkStates("");
/*  398 */         this.instanceMap.remove(Integer.valueOf(instanceid));
       }
     } finally {
/*  401 */       this.lock.unlock();
     }
   }

   public void removeMap(int instanceid) {
/*  406 */     this.lock.lock();
     try {
/*  408 */       if (isMapLoaded(instanceid)) {
/*  409 */         getMap(instanceid).checkStates("");
/*  410 */         this.maps.remove(Integer.valueOf(instanceid));
       }
     } finally {
/*  413 */       this.lock.unlock();
     }
   }

   public MapleMap CreateInstanceMap(int mapid, boolean respawns, boolean npcs, boolean reactors, int instanceid) {
/*  418 */     this.lock.lock();
     try {
/*  420 */       if (isInstanceMapLoaded(instanceid)) {
/*  421 */         return getInstanceMap(instanceid);
       }
     } finally {
/*  424 */       this.lock.unlock();
     }
/*  426 */     MapleData mapData = null;
     try {
/*  428 */       mapData = source.getData(getMapXMLName(mapid));
/*  429 */     } catch (Exception e) {
/*  430 */       return null;
     }
/*  432 */     if (mapData == null) {
/*  433 */       return null;
     }
/*  435 */     MapleData link = mapData.getChildByPath("info/link");
/*  436 */     if (link != null) {
/*  437 */       mapData = source.getData(getMapXMLName(MapleDataTool.getIntConvert("info/link", mapData)));
     }

/*  440 */     float monsterRate = 0.0F;
/*  441 */     if (respawns) {
/*  442 */       MapleData mobRate = mapData.getChildByPath("info/mobRate");
/*  443 */       if (mobRate != null) {
/*  444 */         monsterRate = ((Float)mobRate.getData()).floatValue();
       }
     }
/*  447 */     MapleMap map = new MapleMap(mapid, this.channel, MapleDataTool.getInt("info/returnMap", mapData), monsterRate);
/*  448 */     loadPortals(map, mapData.getChildByPath("portal"));
/*  449 */     map.setTop(MapleDataTool.getInt(mapData.getChildByPath("info/VRTop"), 0));
/*  450 */     map.setLeft(MapleDataTool.getInt(mapData.getChildByPath("info/VRLeft"), 0));
/*  451 */     map.setBottom(MapleDataTool.getInt(mapData.getChildByPath("info/VRBottom"), 0));
/*  452 */     map.setRight(MapleDataTool.getInt(mapData.getChildByPath("info/VRRight"), 0));
/*  453 */     map.setFieldType(MapleDataTool.getInt(mapData.getChildByPath("info/fieldType"), 0));
/*  454 */     List<MapleFoothold> allFootholds = new LinkedList<>();
/*  455 */     Point lBound = new Point();
/*  456 */     Point uBound = new Point();
/*  457 */     for (MapleData footRoot : mapData.getChildByPath("foothold")) {
/*  458 */       for (MapleData footCat : footRoot) {
/*  459 */         for (MapleData footHold : footCat) {






/*  466 */           MapleFoothold fh = new MapleFoothold(new Point(MapleDataTool.getInt(footHold.getChildByPath("x1")), MapleDataTool.getInt(footHold.getChildByPath("y1"))), new Point(MapleDataTool.getInt(footHold.getChildByPath("x2")), MapleDataTool.getInt(footHold.getChildByPath("y2"))), Integer.parseInt(footHold.getName()));
/*  467 */           fh.setPrev((short)MapleDataTool.getInt(footHold.getChildByPath("prev")));
/*  468 */           fh.setNext((short)MapleDataTool.getInt(footHold.getChildByPath("next")));

/*  470 */           if (fh.getX1() < lBound.x) {
/*  471 */             lBound.x = fh.getX1();
           }
/*  473 */           if (fh.getX2() > uBound.x) {
/*  474 */             uBound.x = fh.getX2();
           }
/*  476 */           if (fh.getY1() < lBound.y) {
/*  477 */             lBound.y = fh.getY1();
           }
/*  479 */           if (fh.getY2() > uBound.y) {
/*  480 */             uBound.y = fh.getY2();
           }
/*  482 */           allFootholds.add(fh);
         }
       }
     }
/*  486 */     MapleFootholdTree fTree = new MapleFootholdTree(lBound, uBound);
/*  487 */     for (MapleFoothold fh : allFootholds) {
/*  488 */       fTree.insert(fh);
     }
/*  490 */     map.setFootholds(fTree);
/*  491 */     if (map.getTop() == 0) {
/*  492 */       map.setTop(lBound.y);
     }
/*  494 */     if (map.getBottom() == 0) {
/*  495 */       map.setBottom(uBound.y);
     }
/*  497 */     if (map.getLeft() == 0) {
/*  498 */       map.setLeft(lBound.x);
     }
/*  500 */     if (map.getRight() == 0) {
/*  501 */       map.setRight(uBound.x);
     }
/*  503 */     int bossid = -1;
/*  504 */     String msg = null;
/*  505 */     if (mapData.getChildByPath("info/timeMob") != null) {
/*  506 */       bossid = MapleDataTool.getInt(mapData.getChildByPath("info/timeMob/id"), 0);
/*  507 */       msg = MapleDataTool.getString(mapData.getChildByPath("info/timeMob/message"), null);
     }
/*  509 */     try (DruidPooledConnection con = DatabaseConnection.getInstance().getConnection()) {
/*  510 */       PreparedStatement ps = con.prepareStatement("SELECT * FROM spawns WHERE mid = ?");
/*  511 */       ps.setInt(1, mapid);
/*  512 */       ResultSet rs = ps.executeQuery();
/*  513 */       while (rs.next()) {
/*  514 */         int sqlid = rs.getInt("idd");
/*  515 */         int sqlf = rs.getInt("f");
/*  516 */         boolean sqlhide = false;
/*  517 */         String sqltype = rs.getString("type");
/*  518 */         int sqlfh = rs.getInt("fh");
/*  519 */         int sqlcy = rs.getInt("cy");
/*  520 */         int sqlrx0 = rs.getInt("rx0");
/*  521 */         int sqlrx1 = rs.getInt("rx1");
/*  522 */         int sqlx = rs.getInt("x");
/*  523 */         int sqly = rs.getInt("y");
/*  524 */         int sqlmobTime = rs.getInt("mobtime");
/*  525 */         AbstractLoadedMapleLife sqlmyLife = loadLife(sqlid, sqlf, sqlhide, sqlfh, sqlcy, sqlrx0, sqlrx1, sqlx, sqly, sqltype, mapid);
/*  526 */         if (sqltype.equals("n")) {
/*  527 */           map.addMapObject((MapleMapObject)sqlmyLife); continue;
/*  528 */         }  if (sqltype.equals("m")) {
/*  529 */           MapleMonster monster = (MapleMonster)sqlmyLife;
/*  530 */           map.addMonsterSpawn(monster, sqlmobTime, (byte)-1, null);
         }
       }
/*  533 */     } catch (SQLException e) {
/*  534 */       System.out.println("读取SQL刷Npc和刷新怪物出错.");
     }




/*  540 */     for (MapleData life : mapData.getChildByPath("life")) {
/*  541 */       String type = MapleDataTool.getString(life.getChildByPath("type"));
/*  542 */       String limited = MapleDataTool.getString("limitedname", life, "");
/*  543 */       if ((npcs || !type.equals("n")) && limited.equals("")) {
/*  544 */         AbstractLoadedMapleLife myLife = loadLife(life, MapleDataTool.getString(life.getChildByPath("id")), type, mapid);
/*  545 */         if (myLife instanceof MapleMonster && !BattleConstants.isBattleMap(mapid) && !GameConstants.isNoSpawn(mapid)) {
/*  546 */           MapleMonster mob = (MapleMonster)myLife;
/*  547 */           map.addMonsterSpawn(mob, MapleDataTool.getInt("mobTime", life, 0), (byte)MapleDataTool.getInt("team", life, -1), (mob.getId() == bossid) ? msg : null); continue;
/*  548 */         }  if (myLife instanceof server.life.MapleNPC) {
/*  549 */           map.addMapObject((MapleMapObject)myLife);
         }
       }
     }
/*  553 */     addAreaBossSpawn(map);
/*  554 */     map.setCreateMobInterval((short)MapleDataTool.getInt(mapData.getChildByPath("info/createMobInterval"), ServerConfig.CHANNEL_MONSTER_REFRESH * 1000));
/*  555 */     map.setFixedMob(MapleDataTool.getInt(mapData.getChildByPath("info/fixedMobCapacity"), 0));
/*  556 */     map.setPartyBonusRate(GameConstants.getPartyPlay(mapid, MapleDataTool.getInt(mapData.getChildByPath("info/partyBonusR"), 0)));
/*  557 */     map.loadMonsterRate(true);
/*  558 */     map.setNodes(loadNodes(mapid, mapData));



/*  562 */     if (reactors && mapData.getChildByPath("reactor") != null && !BattleConstants.isBattleMap(mapid)) {
/*  563 */       for (MapleData reactor : mapData.getChildByPath("reactor")) {
/*  564 */         String id = MapleDataTool.getString(reactor.getChildByPath("id"));
/*  565 */         if (id != null) {
/*  566 */           map.spawnReactor(loadReactor(reactor, id, (byte)MapleDataTool.getInt(reactor.getChildByPath("f"), 0)));
         }
       }
     }
     try {
/*  571 */       map.setMapName(MapleDataTool.getString("mapName", nameData.getChildByPath(getMapStringName(mapid)), ""));
/*  572 */       map.setStreetName(MapleDataTool.getString("streetName", nameData.getChildByPath(getMapStringName(mapid)), ""));
/*  573 */     } catch (Exception e) {
/*  574 */       map.setMapName("");
/*  575 */       map.setStreetName("");
     }
/*  577 */     map.setClock((MapleDataTool.getInt(mapData.getChildByPath("info/clock"), 0) > 0));
/*  578 */     map.setEverlast((MapleDataTool.getInt(mapData.getChildByPath("info/everlast"), 0) > 0));
/*  579 */     map.setTown((MapleDataTool.getInt(mapData.getChildByPath("info/town"), 0) > 0));
/*  580 */     map.setSoaring((MapleDataTool.getInt(mapData.getChildByPath("info/needSkillForFly"), 0) > 0));
/*  581 */     map.setForceMove(MapleDataTool.getInt(mapData.getChildByPath("info/lvForceMove"), 0));
/*  582 */     map.setHPDec(MapleDataTool.getInt(mapData.getChildByPath("info/decHP"), 0));
/*  583 */     map.setHPDecInterval(MapleDataTool.getInt(mapData.getChildByPath("info/decHPInterval"), 10000));
/*  584 */     map.setHPDecProtect(MapleDataTool.getInt(mapData.getChildByPath("info/protectItem"), 0));
/*  585 */     map.setForcedReturnMap(MapleDataTool.getInt(mapData.getChildByPath("info/forcedReturn"), 999999999));
/*  586 */     map.setTimeLimit(MapleDataTool.getInt(mapData.getChildByPath("info/timeLimit"), -1));
/*  587 */     map.setFieldLimit(MapleDataTool.getInt(mapData.getChildByPath("info/fieldLimit"), 0));
/*  588 */     map.setFirstUserEnter(MapleDataTool.getString(mapData.getChildByPath("info/onFirstUserEnter"), ""));
/*  589 */     map.setUserEnter(MapleDataTool.getString(mapData.getChildByPath("info/onUserEnter"), ""));
/*  590 */     map.setMiniMapOnOff((MapleDataTool.getInt(mapData.getChildByPath("info/miniMapOnOff"), 0) > 0));
/*  591 */     map.setRecoveryRate(MapleDataTool.getFloat(mapData.getChildByPath("info/recovery"), 1.0F));
/*  592 */     map.setConsumeItemCoolTime(MapleDataTool.getInt(mapData.getChildByPath("info/consumeItemCoolTime"), 0));
/*  593 */     map.setInstanceId(instanceid);
/*  594 */     this.lock.lock();
     try {
/*  596 */       this.instanceMap.put(Integer.valueOf(instanceid), map);
     } finally {
/*  598 */       this.lock.unlock();
     }
/*  600 */     return map;
   }

   public int getLoadedMaps() {
/*  604 */     return this.maps.size();
   }

   public boolean isMapLoaded(int mapId) {
/*  608 */     return this.maps.containsKey(Integer.valueOf(mapId));
   }

   public boolean isInstanceMapLoaded(int instanceid) {
/*  612 */     return this.instanceMap.containsKey(Integer.valueOf(instanceid));
   }

   public void clearLoadedMap() {
/*  616 */     this.lock.lock();
     try {
/*  618 */       this.maps.clear();
     } finally {
/*  620 */       this.lock.unlock();
     }
   }

   public List<MapleMap> getAllLoadedMaps() {
/*  625 */     List<MapleMap> ret = new ArrayList<>();
/*  626 */     this.lock.lock();
     try {
/*  628 */       ret.addAll(this.maps.values());
/*  629 */       ret.addAll(this.instanceMap.values());
     } finally {
/*  631 */       this.lock.unlock();
     }
/*  633 */     return ret;
   }

   public Collection<MapleMap> getAllMaps() {
/*  637 */     return this.maps.values();
   }

   private AbstractLoadedMapleLife loadLife(MapleData life, String id, String type, int mapid) {
/*  641 */     AbstractLoadedMapleLife myLife = MapleLifeFactory.getLife(Integer.parseInt(id), type, mapid);
/*  642 */     if (myLife == null) {
/*  643 */       return null;
     }
/*  645 */     myLife.setCy(MapleDataTool.getInt(life.getChildByPath("cy")));
/*  646 */     MapleData dF = life.getChildByPath("f");
/*  647 */     if (dF != null) {
/*  648 */       myLife.setF(MapleDataTool.getInt(dF));
     }
/*  650 */     myLife.setFh(MapleDataTool.getInt(life.getChildByPath("fh")));
/*  651 */     myLife.setRx0(MapleDataTool.getInt(life.getChildByPath("rx0")));
/*  652 */     myLife.setRx1(MapleDataTool.getInt(life.getChildByPath("rx1")));
/*  653 */     myLife.setPosition(new Point(MapleDataTool.getIntConvert(life.getChildByPath("x")), MapleDataTool.getIntConvert(life.getChildByPath("y"))));

/*  655 */     if (MapleDataTool.getInt("hide", life, 0) == 1 && myLife instanceof server.life.MapleNPC) {
/*  656 */       myLife.setHide(true);
     }
/*  658 */     return myLife;
   }

   private AbstractLoadedMapleLife loadLife(int id, int f, boolean hide, int fh, int cy, int rx0, int rx1, int x, int y, String type, int mapid) {
/*  662 */     AbstractLoadedMapleLife myLife = MapleLifeFactory.getLife(id, type, mapid);
/*  663 */     if (myLife == null) {
/*  664 */       System.out.println("加载npc错误，id：" + id + "  type：" + type);
/*  665 */       return null;
     }
/*  667 */     myLife.setCy(cy);
/*  668 */     myLife.setF(f);
/*  669 */     myLife.setFh(fh);
/*  670 */     myLife.setRx0(rx0);
/*  671 */     myLife.setRx1(rx1);
/*  672 */     myLife.setPosition(new Point(x, y));
/*  673 */     myLife.setHide(hide);
/*  674 */     return myLife;
   }

   private MapleReactor loadReactor(MapleData reactor, String id, byte FacingDirection) {
/*  678 */     MapleReactor myReactor = new MapleReactor(MapleReactorFactory.getReactor(Integer.parseInt(id)), Integer.parseInt(id));
/*  679 */     myReactor.setFacingDirection(FacingDirection);
/*  680 */     myReactor.setPosition(new Point(MapleDataTool.getInt(reactor.getChildByPath("x")), MapleDataTool.getInt(reactor.getChildByPath("y"))));
/*  681 */     myReactor.setDelay(MapleDataTool.getInt(reactor.getChildByPath("reactorTime")) * 1000);
/*  682 */     myReactor.setName(MapleDataTool.getString(reactor.getChildByPath("name"), ""));
/*  683 */     return myReactor;
   }




   private String getMapStringName(int mapid) {
/*  690 */     StringBuilder builder = new StringBuilder();
/*  691 */     if (mapid < 100000000) {
/*  692 */       builder.append("maple");
/*  693 */     } else if (mapid >= 100000000 && mapid < 200000000) {
/*  694 */       builder.append("victoria");
/*  695 */     } else if (mapid >= 200000000 && mapid < 300000000) {
/*  696 */       builder.append("ossyria");
/*  697 */     } else if (mapid >= 300000000 && mapid < 400000000) {
/*  698 */       builder.append("3rd");
/*  699 */     } else if ((mapid >= 400000000 && mapid < 410000000) || (mapid >= 940000000 && mapid < 941000000)) {
/*  700 */       builder.append("grandis");
/*  701 */     } else if (mapid >= 500000000 && mapid < 510000000) {
/*  702 */       builder.append("thai");
/*  703 */     } else if (mapid >= 510000000 && mapid < 520000000) {
/*  704 */       builder.append("EU");
/*  705 */     } else if (mapid >= 540000000 && mapid <= 555000000) {
/*  706 */       builder.append("SG");
/*  707 */     } else if (mapid >= 600000000 && mapid <= 600020600) {
/*  708 */       builder.append("MasteriaGL");
/*  709 */     } else if (mapid >= 677000000 && mapid < 678000000) {
/*  710 */       builder.append("Episode1GL");
/*  711 */     } else if (mapid >= 680000000 && mapid < 681000000) {
/*  712 */       builder.append("global");
/*  713 */     } else if ((mapid >= 680100000 && mapid < 681100000) || (mapid >= 682000000 && mapid < 683000000)) {
/*  714 */       builder.append("HalloweenGL");
/*  715 */     } else if (mapid >= 686000000 && mapid < 687000000) {
/*  716 */       builder.append("event_6th");
/*  717 */     } else if (mapid >= 689010000 && mapid < 690000000) {
/*  718 */       builder.append("Pink ZakumGL");
/*  719 */     } else if (mapid == 689000000 || mapid == 689000010) {
/*  720 */       builder.append("CTF_GL");
/*  721 */     } else if ((mapid >= 690010000 && mapid < 700000000) || (mapid >= 746000000 && mapid < 746100000)) {
/*  722 */       builder.append("boost");
/*  723 */     } else if (mapid >= 700000000 && mapid < 742000000) {
/*  724 */       builder.append("chinese");
/*  725 */     } else if (mapid >= 743000000 && mapid < 744000000) {
/*  726 */       builder.append("taiwan");
/*  727 */     } else if (mapid >= 744000000 && mapid < 800000000) {
/*  728 */       builder.append("chinese");
/*  729 */     } else if (mapid >= 860000000 && mapid < 861000000) {
/*  730 */       builder.append("aquaroad");
/*  731 */     } else if (mapid >= 863000000 && mapid < 864000000) {
/*  732 */       builder.append("masteria");
/*  733 */     } else if (mapid >= 800000000 && mapid < 900000000) {
/*  734 */       builder.append("jp");
     } else {
/*  736 */       builder.append("etc");
     }
/*  738 */     builder.append("/");
/*  739 */     builder.append(mapid);
/*  740 */     return builder.toString();
   }

   public void setChannel(int channel) {
/*  744 */     this.channel = channel;
   }




   private void addAreaBossSpawn(MapleMap map) {
/*  751 */     int monsterid = -1;
/*  752 */     int mobtime = -1;
/*  753 */     String msg = null;
/*  754 */     boolean shouldSpawn = true;
/*  755 */     boolean sendWorldMsg = false;
/*  756 */     Point pos1 = null, pos2 = null, pos3 = null;

/*  758 */     switch (map.getId()) {
       case 104010200:
/*  760 */         mobtime = 1200;
/*  761 */         monsterid = 2220000;
/*  762 */         msg = "天气凉快了就会出现红蜗牛王。";
/*  763 */         pos1 = new Point(189, 2);
/*  764 */         pos2 = new Point(478, 250);
/*  765 */         pos3 = new Point(611, 489);
         break;
       case 102020500:
/*  768 */         mobtime = 1200;
/*  769 */         monsterid = 3220000;
/*  770 */         msg = "树妖王出现了。";
/*  771 */         pos1 = new Point(1121, 2130);
/*  772 */         pos2 = new Point(483, 2171);
/*  773 */         pos3 = new Point(1474, 1706);
         break;
       case 100020101:
/*  776 */         mobtime = 1200;
/*  777 */         monsterid = 6130101;
/*  778 */         msg = "什么地方出现了巨大的蘑菇。";
/*  779 */         pos1 = new Point(-311, 201);
/*  780 */         pos2 = new Point(-903, 197);
/*  781 */         pos3 = new Point(-568, 196);
         break;
       case 100020301:
/*  784 */         mobtime = 1200;
/*  785 */         monsterid = 8220007;
/*  786 */         msg = "什么地方出现了巨大的蓝色蘑菇。";
/*  787 */         pos1 = new Point(-188, -657);
/*  788 */         pos2 = new Point(625, -660);
/*  789 */         pos3 = new Point(508, -648);
         break;
       case 105010301:
/*  792 */         mobtime = 1200;
/*  793 */         monsterid = 6300005;
/*  794 */         msg = "什么地方出现了笼罩着阴暗气息的巨大蘑菇。";
/*  795 */         pos1 = new Point(-130, -773);
/*  796 */         pos2 = new Point(504, -760);
/*  797 */         pos3 = new Point(608, -641);
         break;
       case 120030500:
/*  800 */         mobtime = 1200;
/*  801 */         monsterid = 5220001;
/*  802 */         msg = "从沙滩里慢慢的走出了一只巨居蟹。";
/*  803 */         pos1 = new Point(-355, 179);
/*  804 */         pos2 = new Point(-1283, -113);
/*  805 */         pos3 = new Point(-571, -593);
         break;
       case 250010304:
/*  808 */         mobtime = 2100;
/*  809 */         monsterid = 7220000;
/*  810 */         msg = "随着微弱的口哨声，肯德熊出现了。";
/*  811 */         pos1 = new Point(-210, 33);
/*  812 */         pos2 = new Point(-234, 393);
/*  813 */         pos3 = new Point(-654, 33);
         break;
       case 200010300:
/*  816 */         mobtime = 1200;
/*  817 */         monsterid = 8220000;
/*  818 */         msg = "艾利杰出现了。";
/*  819 */         pos1 = new Point(665, 83);
/*  820 */         pos2 = new Point(672, -217);
/*  821 */         pos3 = new Point(-123, -217);
         break;
       case 250010503:
/*  824 */         mobtime = 1800;
/*  825 */         monsterid = 7220002;
/*  826 */         msg = "周边的妖气慢慢浓厚，可以听到诡异的猫叫声。";
/*  827 */         pos1 = new Point(-303, 543);
/*  828 */         pos2 = new Point(227, 543);
/*  829 */         pos3 = new Point(719, 543);
         break;
       case 222010310:
/*  832 */         mobtime = 2700;
/*  833 */         monsterid = 7220001;
/*  834 */         msg = "在阴暗的月光中随着九尾狐的哭声，可以感受到它阴气。";
/*  835 */         pos1 = new Point(-169, -147);
/*  836 */         pos2 = new Point(-517, 93);
/*  837 */         pos3 = new Point(247, 93);
         break;
       case 103030400:
/*  840 */         mobtime = 1800;
/*  841 */         monsterid = 6220000;
/*  842 */         msg = "从沼泽出现了巨大的多尔。";
/*  843 */         pos1 = new Point(-831, 109);
/*  844 */         pos2 = new Point(1525, -75);
/*  845 */         pos3 = new Point(-511, 107);
         break;
       case 101040300:
/*  848 */         mobtime = 1800;
/*  849 */         monsterid = 5220002;
/*  850 */         msg = "蓝雾慢慢散去，浮士德慢慢的显现了出来。";
/*  851 */         pos1 = new Point(600, -600);
/*  852 */         pos2 = new Point(600, -800);
/*  853 */         pos3 = new Point(600, -300);
         break;
       case 220050200:
/*  856 */         mobtime = 1500;
/*  857 */         monsterid = 5220003;
/*  858 */         msg = "嘀嗒嘀嗒! 随着规则的指针声出现了提莫。";
/*  859 */         pos1 = new Point(-467, 1032);
/*  860 */         pos2 = new Point(532, 1032);
/*  861 */         pos3 = new Point(-47, 1032);
         break;
       case 221040301:
/*  864 */         mobtime = 2400;
/*  865 */         monsterid = 6220001;
/*  866 */         msg = "厚重的机器运作声，朱诺出现了!";
/*  867 */         pos1 = new Point(-4134, 416);
/*  868 */         pos2 = new Point(-4283, 776);
/*  869 */         pos3 = new Point(-3292, 776);
         break;
       case 240040401:
/*  872 */         mobtime = 7200;
/*  873 */         monsterid = 8220003;
/*  874 */         msg = "大海兽出现了。";
/*  875 */         pos1 = new Point(-15, 2481);
/*  876 */         pos2 = new Point(127, 1634);
/*  877 */         pos3 = new Point(159, 1142);
         break;
       case 260010201:
/*  880 */         mobtime = 3600;
/*  881 */         monsterid = 3220001;
/*  882 */         msg = "从沙尘中可以看到大宇的身影。";
/*  883 */         pos1 = new Point(-215, 275);
/*  884 */         pos2 = new Point(298, 275);
/*  885 */         pos3 = new Point(592, 275);
         break;
       case 251010102:
/*  888 */         mobtime = 3600;
/*  889 */         monsterid = 5220004;
/*  890 */         msg = "大王蜈蚣出现了。";
/*  891 */         pos1 = new Point(-41, 124);
/*  892 */         pos2 = new Point(-173, 126);
/*  893 */         pos3 = new Point(79, 118);
         break;
       case 261030000:
/*  896 */         mobtime = 2700;
/*  897 */         monsterid = 8220002;
/*  898 */         msg = "吉米拉出现了。";
/*  899 */         pos1 = new Point(-1094, -405);
/*  900 */         pos2 = new Point(-772, -116);
/*  901 */         pos3 = new Point(-108, 181);
         break;
       case 230020100:
/*  904 */         mobtime = 2700;
/*  905 */         monsterid = 4220000;
/*  906 */         msg = "在海草中间，出现了奇怪的蛤蚌。";
/*  907 */         pos1 = new Point(-291, -20);
/*  908 */         pos2 = new Point(-272, -500);
/*  909 */         pos3 = new Point(-462, 640);
         break;
       case 103020320:
/*  912 */         mobtime = 1800;
/*  913 */         monsterid = 5090000;
/*  914 */         msg = "在地铁的阴影中出现了什么东西。";
/*  915 */         pos1 = new Point(79, 174);
/*  916 */         pos2 = new Point(-223, 296);
/*  917 */         pos3 = new Point(80, 275);
         break;
       case 103020420:
/*  920 */         mobtime = 1800;
/*  921 */         monsterid = 5090000;
/*  922 */         msg = "在地铁的阴影中出现了什么东西。";
/*  923 */         pos1 = new Point(2241, 301);
/*  924 */         pos2 = new Point(1990, 301);
/*  925 */         pos3 = new Point(1684, 307);
         break;
       case 261020300:
/*  928 */         mobtime = 2700;
/*  929 */         monsterid = 7090000;
/*  930 */         msg = "自动警备系统出现了。";
/*  931 */         pos1 = new Point(312, 157);
/*  932 */         pos2 = new Point(539, 136);
/*  933 */         pos3 = new Point(760, 141);
         break;
       case 261020401:
/*  936 */         mobtime = 2700;
/*  937 */         monsterid = 8090000;
/*  938 */         msg = "迪特和罗伊出现了。";
/*  939 */         pos1 = new Point(-263, 155);
/*  940 */         pos2 = new Point(-436, 122);
/*  941 */         pos3 = new Point(22, 144);
         break;
       case 250020300:
/*  944 */         mobtime = 2700;
/*  945 */         monsterid = 5090001;
/*  946 */         msg = "仙人玩偶出现了。";
/*  947 */         pos1 = new Point(1208, 27);
/*  948 */         pos2 = new Point(1654, 40);
/*  949 */         pos3 = new Point(927, -502);
         break;
       case 211050000:
/*  952 */         mobtime = 2700;
/*  953 */         monsterid = 6090001;
/*  954 */         msg = "被束缚在冰里的魔女睁开了眼睛。";
/*  955 */         pos1 = new Point(-233, -431);
/*  956 */         pos2 = new Point(-370, -426);
/*  957 */         pos3 = new Point(-526, -420);
         break;
       case 261010003:
/*  960 */         mobtime = 2700;
/*  961 */         monsterid = 6090004;
/*  962 */         msg = "陆陆猫出现了。";
/*  963 */         pos1 = new Point(-861, 301);
/*  964 */         pos2 = new Point(-703, 301);
/*  965 */         pos3 = new Point(-426, 287);
         break;
       case 222010300:
/*  968 */         mobtime = 2700;
/*  969 */         monsterid = 6090003;
/*  970 */         msg = "书生鬼出现了。";
/*  971 */         pos1 = new Point(1300, -400);
/*  972 */         pos2 = new Point(1100, -100);
/*  973 */         pos3 = new Point(1100, 100);
         break;
       case 251010101:
/*  976 */         mobtime = 2700;
/*  977 */         monsterid = 6090002;
/*  978 */         msg = "竹林里出现了一个来历不明的青竹武士，只要打碎小竹片，就可让青竹武士大发雷霆而葬失自制力，并将他打倒。";
/*  979 */         pos1 = new Point(-15, -449);
/*  980 */         pos2 = new Point(-114, -442);
/*  981 */         pos3 = new Point(-255, -446);
         break;
       case 211041400:
/*  984 */         mobtime = 2700;
/*  985 */         monsterid = 6090000;
/*  986 */         msg = "黑山老妖出现了！";
/*  987 */         pos1 = new Point(1672, 82);
/*  988 */         pos2 = new Point(2071, 10);
/*  989 */         pos3 = new Point(1417, 57);
         break;
       case 105030500:
/*  992 */         mobtime = 2700;
/*  993 */         monsterid = 8130100;
/*  994 */         msg = "蝙蝠怪出现了。";
/*  995 */         pos1 = new Point(1275, -399);
/*  996 */         pos2 = new Point(1254, -412);
/*  997 */         pos3 = new Point(1058, -427);
         break;
       case 105020400:
/* 1000 */         mobtime = 2700;
/* 1001 */         monsterid = 8220008;
/* 1002 */         msg = "出现了一个奇怪的商店。";
/* 1003 */         pos1 = new Point(-163, 82);
/* 1004 */         pos2 = new Point(958, 107);
/* 1005 */         pos3 = new Point(706, -206);
         break;
       case 211040101:
/* 1008 */         mobtime = 3600;
/* 1009 */         monsterid = 8220001;
/* 1010 */         msg = "驮狼雪人出现了。";
/* 1011 */         pos1 = new Point(485, 244);
/* 1012 */         pos2 = new Point(-60, 249);
/* 1013 */         pos3 = new Point(208, 255);
         break;
       case 209000000:
/* 1016 */         mobtime = 300;
/* 1017 */         monsterid = 9500317;
/* 1018 */         msg = "小雪人出现了。";
/* 1019 */         pos1 = new Point(-115, 154);
/* 1020 */         pos2 = new Point(-115, 154);
/* 1021 */         pos3 = new Point(-115, 154);
         break;
       case 677000001:
/* 1024 */         mobtime = 60;
/* 1025 */         monsterid = 9400612;
/* 1026 */         msg = "牛魔王出现了。";
/* 1027 */         pos1 = new Point(99, 60);
/* 1028 */         pos2 = new Point(99, 60);
/* 1029 */         pos3 = new Point(99, 60);
         break;
       case 677000003:
/* 1032 */         mobtime = 60;
/* 1033 */         monsterid = 9400610;
/* 1034 */         msg = "黑暗独角兽出现了。";
/* 1035 */         pos1 = new Point(6, 35);
/* 1036 */         pos2 = new Point(6, 35);
/* 1037 */         pos3 = new Point(6, 35);
         break;
       case 677000005:
/* 1040 */         mobtime = 60;
/* 1041 */         monsterid = 9400609;
/* 1042 */         msg = "印第安老斑鸠出现了。";
/* 1043 */         pos1 = new Point(-277, 78);
/* 1044 */         pos2 = new Point(547, 86);
/* 1045 */         pos3 = new Point(-347, 80);
         break;
       case 677000007:
/* 1048 */         mobtime = 60;
/* 1049 */         monsterid = 9400611;
/* 1050 */         msg = "雪之猫女出现了。";
/* 1051 */         pos1 = new Point(117, 73);
/* 1052 */         pos2 = new Point(117, 73);
/* 1053 */         pos3 = new Point(117, 73);
         break;
       case 677000009:
/* 1056 */         mobtime = 60;
/* 1057 */         monsterid = 9400613;
/* 1058 */         msg = "沃勒福出现了。";
/* 1059 */         pos1 = new Point(85, 66);
/* 1060 */         pos2 = new Point(85, 66);
/* 1061 */         pos3 = new Point(85, 66);
         break;
       case 931000500:
       case 931000502:
/* 1065 */         mobtime = 3600;
/* 1066 */         monsterid = 9304005;
/* 1067 */         msg = "美洲豹栖息地出现 剑齿豹 ，喜欢此坐骑的弩豹游侠职业可以前往抓捕。";
/* 1068 */         pos1 = new Point(-872, -332);
/* 1069 */         pos2 = new Point(409, -572);
/* 1070 */         pos3 = new Point(-131, 0);
/* 1071 */         shouldSpawn = false;
/* 1072 */         sendWorldMsg = true;
         break;
       case 931000501:
       case 931000503:
/* 1076 */         mobtime = 7200;
/* 1077 */         monsterid = 9304006;
/* 1078 */         msg = "美洲豹栖息地出现 雪豹 ，喜欢此坐骑的弩豹游侠职业可以前往抓捕。";
/* 1079 */         pos1 = new Point(-872, -332);
/* 1080 */         pos2 = new Point(409, -572);
/* 1081 */         pos3 = new Point(-131, 0);
/* 1082 */         shouldSpawn = false;
/* 1083 */         sendWorldMsg = true;
         break;
     }
/* 1086 */     if (monsterid > 0) {
/* 1087 */       map.addAreaMonsterSpawn(MapleLifeFactory.getMonster(monsterid), pos1, pos2, pos3, mobtime, msg, shouldSpawn, sendWorldMsg);
     }
   }

   private void loadPortals(MapleMap map, MapleData port) {
/* 1092 */     if (port == null) {
       return;
     }
/* 1095 */     int nextDoorPortal = 128;
/* 1096 */     for (MapleData portal : port.getChildren()) {
/* 1097 */       MaplePortal myPortal = new MaplePortal(MapleDataTool.getInt(portal.getChildByPath("pt")));
/* 1098 */       myPortal.setName(MapleDataTool.getString(portal.getChildByPath("pn")));
/* 1099 */       myPortal.setTarget(MapleDataTool.getString(portal.getChildByPath("tn")));
/* 1100 */       myPortal.setTargetMapId(MapleDataTool.getInt(portal.getChildByPath("tm")));
/* 1101 */       myPortal.setPosition(new Point(MapleDataTool.getInt(portal.getChildByPath("x")), MapleDataTool.getInt(portal.getChildByPath("y"))));
/* 1102 */       String script = MapleDataTool.getString("script", portal, null);
/* 1103 */       if (script != null && script.equals("")) {
/* 1104 */         script = null;
       }
/* 1106 */       myPortal.setScriptName(script);

/* 1108 */       if (myPortal.getType() == 6) {
/* 1109 */         myPortal.setId(nextDoorPortal);
/* 1110 */         nextDoorPortal++;
       } else {
/* 1112 */         myPortal.setId(Integer.parseInt(portal.getName()));
       }
/* 1114 */       map.addPortal(myPortal);
     }
   }

   private MapleNodes loadNodes(int mapid, MapleData mapData) {
/* 1119 */     MapleNodes nodeInfo = new MapleNodes(mapid);
/* 1120 */     if (mapData.getChildByPath("nodeInfo") != null) {
/* 1121 */       for (MapleData node : mapData.getChildByPath("nodeInfo")) {
         try {
/* 1123 */           if (node.getName().equals("start")) {
/* 1124 */             nodeInfo.setNodeStart(MapleDataTool.getInt(node, 0)); continue;
/* 1125 */           }  if (node.getName().equals("end")) {
/* 1126 */             nodeInfo.setNodeEnd(MapleDataTool.getInt(node, 0)); continue;
/* 1127 */           }  if (node.getName().equals("edgeInfo")) {
/* 1128 */             for (MapleData edeginfo : node) {
/* 1129 */               if (!edeginfo.getName().equals("desc")) {
/* 1130 */                 int node1 = MapleDataTool.getInt("node1", edeginfo, 0);
/* 1131 */                 int node2 = MapleDataTool.getInt("node2", edeginfo, 0);

                 List<Integer> list;
/* 1134 */                 if ((list = nodeInfo.getNodes12().get(Integer.valueOf(node1))) == null) {
/* 1135 */                   list = new ArrayList<>();
/* 1136 */                   nodeInfo.getNodes12().put(Integer.valueOf(node1), list);
                 }
/* 1138 */                 list.add(Integer.valueOf(node2));
                 List<Integer> list2;
/* 1140 */                 if ((list2 = nodeInfo.getNodes12().get(Integer.valueOf(node2))) == null) {
/* 1141 */                   list2 = new ArrayList<>();
/* 1142 */                   nodeInfo.getNodes12().put(Integer.valueOf(node2), list2);
                 }
/* 1144 */                 list2.add(Integer.valueOf(node1));
               }
             }  continue;
           }
/* 1148 */           List<Integer> edges = new ArrayList<>();
/* 1149 */           if (node.getChildByPath("edge") != null) {
/* 1150 */             for (MapleData edge : node.getChildByPath("edge")) {
/* 1151 */               edges.add(Integer.valueOf(MapleDataTool.getInt(edge, -1)));
             }
           }
/* 1154 */           MapleNodes.MapleStopInfo stopInfo = null;
/* 1155 */           MapleData stopInfoData = node.getChildByPath("stopInfo");
/* 1156 */           if (stopInfoData != null) {
/* 1157 */             ArrayList<Pair<String, String>> stopInfos = new ArrayList<>();
/* 1158 */             int stopDuration = MapleDataTool.getInt(stopInfoData.getChildByPath("stopDuration"), -1);
/* 1159 */             String scriptName = MapleDataTool.getString(stopInfoData.getChildByPath("scriptName"), "");
/* 1160 */             int sayTic = MapleDataTool.getInt(stopInfoData.getChildByPath("sayTic"), -1);
/* 1161 */             int chatBalloon = MapleDataTool.getInt(stopInfoData.getChildByPath("chatBalloon"), -1);
/* 1162 */             boolean isWeather = (MapleDataTool.getInt(stopInfoData.getChildByPath("isWeather"), 0) > 0);
/* 1163 */             boolean isRepeat = (MapleDataTool.getInt(stopInfoData.getChildByPath("isRepeat"), 0) > 0);
/* 1164 */             boolean isRandom = (MapleDataTool.getInt(stopInfoData.getChildByPath("isRandom"), 0) > 0);
/* 1165 */             if (stopInfoData.getChildByPath("sayInfo") != null) {
/* 1166 */               for (MapleData sayInfo : stopInfoData.getChildByPath("sayInfo")) {
/* 1167 */                 stopInfos.add(new Pair(MapleDataTool.getString(sayInfo.getChildByPath("say"), ""), MapleDataTool.getString(sayInfo.getChildByPath("say"), "")));
               }
             }
/* 1170 */             stopInfo = new MapleNodes.MapleStopInfo(scriptName, stopDuration, sayTic, chatBalloon, isWeather, isRepeat, isRandom, stopInfos);
           }





/* 1177 */           MapleNodes.MapleNodeInfo mni = new MapleNodes.MapleNodeInfo(Integer.parseInt(node.getName()), MapleDataTool.getIntConvert("key", node, 0), MapleDataTool.getIntConvert("x", node, 0), MapleDataTool.getIntConvert("y", node, 0), MapleDataTool.getIntConvert("attr", node, 0), edges, stopInfo);


/* 1180 */           nodeInfo.addNode(mni);
         }
/* 1182 */         catch (NumberFormatException numberFormatException) {}
       }

/* 1185 */       nodeInfo.sortNodes();
     }
/* 1187 */     for (int i = 1; i <= 7; i++) {
/* 1188 */       if (mapData.getChildByPath(String.valueOf(i)) != null && mapData.getChildByPath(i + "/obj") != null) {
/* 1189 */         for (MapleData node : mapData.getChildByPath(i + "/obj")) {
/* 1190 */           if (node.getChildByPath("SN_count") != null && node.getChildByPath("speed") != null) {
/* 1191 */             int sn_count = MapleDataTool.getIntConvert("SN_count", node, 0);
/* 1192 */             String name = MapleDataTool.getString("name", node, "");
/* 1193 */             int speed = MapleDataTool.getIntConvert("speed", node, 0);
/* 1194 */             if (sn_count <= 0 || speed <= 0 || name.equals("")) {
               continue;
             }
/* 1197 */             List<Integer> SN = new ArrayList<>();
/* 1198 */             for (int x = 0; x < sn_count; x++) {
/* 1199 */               SN.add(Integer.valueOf(MapleDataTool.getIntConvert("SN" + x, node, 0)));
             }






/* 1207 */             MapleNodes.MaplePlatform mni = new MapleNodes.MaplePlatform(name, MapleDataTool.getIntConvert("start", node, 2), speed, MapleDataTool.getIntConvert("x1", node, 0), MapleDataTool.getIntConvert("y1", node, 0), MapleDataTool.getIntConvert("x2", node, 0), MapleDataTool.getIntConvert("y2", node, 0), MapleDataTool.getIntConvert("r", node, 0), SN);
/* 1208 */             nodeInfo.addPlatform(mni); continue;
/* 1209 */           }  if (node.getChildByPath("tags") != null) {
/* 1210 */             String name = MapleDataTool.getString("tags", node, "");
/* 1211 */             nodeInfo.addFlag(new Pair(name, Integer.valueOf(name.endsWith("3") ? 1 : 0)));
           }
         }
       }
     }

/* 1217 */     if (mapData.getChildByPath("area") != null)
     {

/* 1220 */       for (MapleData area : mapData.getChildByPath("area")) {
/* 1221 */         int x1 = MapleDataTool.getInt(area.getChildByPath("x1"));
/* 1222 */         int y1 = MapleDataTool.getInt(area.getChildByPath("y1"));
/* 1223 */         int x2 = MapleDataTool.getInt(area.getChildByPath("x2"));
/* 1224 */         int y2 = MapleDataTool.getInt(area.getChildByPath("y2"));
/* 1225 */         Rectangle mapArea = new Rectangle(x1, y1, x2 - x1, y2 - y1);
/* 1226 */         nodeInfo.addMapleArea(mapArea);
       }
     }
/* 1229 */     if (mapData.getChildByPath("CaptureTheFlag") != null) {
/* 1230 */       MapleData mc = mapData.getChildByPath("CaptureTheFlag");
/* 1231 */       for (MapleData area : mc) {
/* 1232 */         nodeInfo.addGuardianSpawn(new Point(MapleDataTool.getInt(area.getChildByPath("FlagPositionX")), MapleDataTool.getInt(area.getChildByPath("FlagPositionY"))), area.getName().startsWith("Red") ? 0 : 1);
       }
     }
/* 1235 */     if (mapData.getChildByPath("directionInfo") != null) {
/* 1236 */       MapleData mc = mapData.getChildByPath("directionInfo");
/* 1237 */       for (MapleData area : mc) {
/* 1238 */         MapleNodes.DirectionInfo di = new MapleNodes.DirectionInfo(Integer.parseInt(area.getName()), MapleDataTool.getInt("x", area, 0), MapleDataTool.getInt("y", area, 0), (MapleDataTool.getInt("forcedInput", area, 0) > 0));
/* 1239 */         if (area.getChildByPath("EventQ") != null) {
/* 1240 */           for (MapleData event : area.getChildByPath("EventQ")) {
/* 1241 */             di.eventQ.add(MapleDataTool.getString(event));
           }
         } else {
/* 1244 */           System.out.println("[loadNodes] 地图: " + mapid + " 没有找到EventQ.");
         }
/* 1246 */         nodeInfo.addDirection(Integer.parseInt(area.getName()), di);
       }
     }
/* 1249 */     if (mapData.getChildByPath("monsterCarnival") != null) {
/* 1250 */       MapleData mc = mapData.getChildByPath("monsterCarnival");
/* 1251 */       if (mc.getChildByPath("mobGenPos") != null) {
/* 1252 */         for (MapleData area : mc.getChildByPath("mobGenPos")) {
/* 1253 */           nodeInfo.addMonsterPoint(MapleDataTool.getInt(area.getChildByPath("x")), 
/* 1254 */               MapleDataTool.getInt(area.getChildByPath("y")), 
/* 1255 */               MapleDataTool.getInt(area.getChildByPath("fh")), 
/* 1256 */               MapleDataTool.getInt(area.getChildByPath("cy")), 
/* 1257 */               MapleDataTool.getInt("team", area, -1));
         }
       }
/* 1260 */       if (mc.getChildByPath("mob") != null) {
/* 1261 */         for (MapleData area : mc.getChildByPath("mob")) {
/* 1262 */           nodeInfo.addMobSpawn(MapleDataTool.getInt(area.getChildByPath("id")), MapleDataTool.getInt(area.getChildByPath("spendCP")));
         }
       }
/* 1265 */       if (mc.getChildByPath("guardianGenPos") != null) {
/* 1266 */         for (MapleData area : mc.getChildByPath("guardianGenPos")) {
/* 1267 */           nodeInfo.addGuardianSpawn(new Point(MapleDataTool.getInt(area.getChildByPath("x")), MapleDataTool.getInt(area.getChildByPath("y"))), MapleDataTool.getInt("team", area, -1));
         }
       }
/* 1270 */       if (mc.getChildByPath("skill") != null) {
/* 1271 */         for (MapleData area : mc.getChildByPath("skill")) {
/* 1272 */           nodeInfo.addSkillId(MapleDataTool.getInt(area));
         }
       }
     }
/* 1276 */     return nodeInfo;
   }
 }


/* Location:              C:\PGX\Server.jar!\server\maps\MapleMapFactory.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */